﻿using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace WPFExcelReport
{

    using zl_u8 = Byte;
    using zl_u16 = System.UInt16;
    using zl_u32 = System.UInt32;
    using zl_s8 = SByte;
    using zl_s16 = System.Int16;
    using zl_s32 = System.Int32;
    using zl_bool = System.Int32;
    using zl_boolean = System.UInt32;
    using zl_char = System.SByte;
    using zl_int = System.Int32;
    using IP_ADDR = System.UInt32;
    using ZLDevHandler = System.UInt32;
    
 
    public unsafe partial class ZLAN2
    {
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_StartSearchDev", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u16 StartSearchDev();
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetDevID", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8* GetDevID(zl_u8 nNum);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetDevName", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8[] GetDevName(zl_u8 nNum);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetStatus", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8 GetStatus(zl_u8 nNum);

        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetIPMode", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8 GetIPMode(zl_u8 nNum);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetIP", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_s8[] GetIP(zl_u8 nNum);

        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetPort", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u16 GetPort(zl_u8 nNum);

        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetWorkMode", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8 GetWorkMode(zl_u8 nNum);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetNetMask", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_s8[] GetNetMask(zl_u8 nNum);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetGateWay", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_s8[] GetGateWay(zl_u8 nNum);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetDestName", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_s8[] GetDestName(zl_u8 nNum);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetDestPort", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u16 GetDestPort(zl_u8 nNum);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetBaudrateIndex", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8 GetBaudrateIndex(zl_u8 nNum);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetDataBits", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8 GetDataBits(zl_u8 nNum);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetParity", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8 GetParity(zl_u8 nNum);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_GetFlowControl", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8 GetFlowControl(zl_u8 nNum);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_SetParam", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_s8 SetParam(zl_u8 nNum);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_SetDevName", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_s8 SetDevName(zl_u8 nNum, zl_s8* DevName);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_SetIPMode", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8 SetIPMode(zl_u8 nNum, zl_u8 IPMode);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_SetIP", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u32 SetIP(zl_u8 nNum, zl_s8* IP);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_SetPort", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u16 SetPort(zl_u8 nNum, zl_u16 Port);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_SetWorkMode", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8 SetWorkMode(zl_u8 nNum, zl_u8 WorkMode);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_SetNetMask", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u32 SetNetMask(zl_u8 nNum, zl_s8* NetMask);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_SetGateWay", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u32 SetGateWay(zl_u8 nNum, zl_s8* GateWay);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_SetDestName", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_s8 SetDestName(zl_u8 nNum, zl_s8* DestName);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_SetDestPort", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u16 SetDestPort(zl_u8 nNum, zl_u16 DestPort);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_SetBaudrateIndex", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8 SetBaudrateIndex(zl_u8 nNum, zl_u8 Baudrate);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_SetDataBits", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8 SetDataBits(zl_u8 nNum, zl_u8 DataBits);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_SetParity", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8 SetParity(zl_u8 nNum, zl_u8 Parity);
        [DllImport("ZLDevManageV2.dll", EntryPoint = "ZLDM_SetFlowControl", CallingConvention = CallingConvention.StdCall)]
        public static extern zl_u8 SetFlowControl(zl_u8 nNum, zl_u8 FlowControl);  
    }
    public unsafe partial class ZLAN2
    {
        public const int ID_LEN = 6;
        public const int WM_USER = 0x0400;
        public const int MAX_DEV_NAME_LEN = 10;//参数结构体中设备名称的最长长度
        public const int DNS_NAME_MAX_LEN = 30; //目的地址的最长长度  
        public const int WORK_MODE_SERVER = 0; //参数结构体中 WorkMode 取值 
        public const int WORK_MODE_CLIENT = 1;
        public const int IP_MODE_STATIC = 0; //参数结构体中 IPMode 的取值 
        public const int IP_MODE_DHCP = 1;
        public const int DEST_MODE_STATIC = 0; //参数结构体中 DestMode 的取值 
        public const int DEST_MODE_DYNAMIC = 1;
        public const int FLOW_C_NONE = 0; //参数结构体中 FlowControl 的取值 
        public const int FLOW_C_CTS_RTS = 1;
        public const int PARAM_PARITY_NONE = 0; //参数结构体中 Parity 的取值 
        public const int PARAM_PARITY_ODD = 1;
        public const int PARAM_PARITY_EVEN = 2;
        public const int PARAM_PARITY_MARK = 3;
        public const int PARAM_PARITY_SPACE = 4;
        public const int DATA_BITS_8 = 0; //参数结构体中 BaudrateIndex的取值 
        public const int DATA_BITS_7 = 1;
        public const int DATA_BITS_6 = 2;
        public const int DATA_BITS_5 = 3;
        public const int BANDURATE_1200 = 0;//参数结构体中 DataBits 的取值 
        public const int BANDURATE_2400 = 1;
        public const int BANDURATE_4800 = 2;
        public const int BANDURATE_7200 = 3;
        public const int BANDURATE_9600 = 4;
        public const int BANDURATE_14400 = 5;
        public const int BANDURATE_19200 = 6;
        public const int BANDURATE_28800 = 7;
        public const int BANDURATE_38400 = 8;
        public const int BANDURATE_57600 = 9;
        public const int BANDURATE_76800 = 10;
        public const int BANDURATE_115200 = 11;
        public const int APP_PRO_NONE = 0; //转化协议类型定义 
        public const int APP_PRO_MODBUS_RTU = 1;
        public const int MODBUS_TCP_SERVER_PORT = 502;
        public const int MODBUS_TCP_DATA_START = 6;
        public const int DEV_STATUS_CLOSED = 0;
        public const int DEV_STATUS_OPENED = 1;
        public const int ZLDM_HANDLER_ARRAY_MIN_SIZE = 256; //设备句柄数据的建议最小值  
        public const int ZLDM_FAST_SEND = 0;//快速发送模式 
        public const int ZLDM_BULK_SEND = 1; //大数据量发送模式
        public const int ZLDM_CALL_MESSAGE = 0x00;  
        public const int ZLDM_CALL_BACK = 0x02;  

        public const int WM_ZLDM_RECV = (WM_USER + 1920); //消息定义 
        public const int ZLDM_VER = 9;  //函数库版本号 

        public const int WM_WINDOWPOSCHANGED = 0x0047;
        public const int WM_WINDOWPOSCHANGING = 0x0046;
        public const int WM_NCMOUSEMOVE = 0xa0;
        public const int WM_NCLBUTTONDOWN = 0xA1;
        public const int WM_NCLBUTTONUP = 0xA2;
        public const int WM_NCLBUTTONDBLCLK = 0xA3;
        public const int WM_NCRBUTTONDOWN = 0xA4;
        public const int WM_NCRBUTTONUP = 0xA5;
        public const int WM_CAPTURECHANGED = 0x0215;
        public const int WM_EXITSIZEMOVE = 0x0232;
        public const int WM_ENTERSIZEMOVE = 0x0231;
        public const int WM_MOVE = 0x0003;
        public const int WM_MOVING = 0x0216;
        public const int WM_KILLFOCUS = 0x0008;
        public const int WM_SETFOCUS = 0x0007;
        public const int WM_ACTIVATE = 0x0006;
        public const int WM_NCHITTEST = 0x0084;

        public const int WA_INACTIVE = 0x0000;
    }
}